﻿<script>
function mo_form_sua(ten_dn){
	document.frmDLsua.ten_dn.value=ten_dn;
	document.frmDLsua.submit();
	}

function thuchienxoa(){
	var f = document.frmdstv;
	var dstv = "";
	if(f.chkxoa.length != undefined){  //trong tinh trang co 2 cai de xoa
		var len = f.chkxoa.length;
		for( var i = 0; i < len; i++){
			if( f.chkxoa[i].checked){
				if( dstv == ""){
					dstv = f.chkxoa[i].value;
				}else dstv = dstv+","+f.chkxoa[i].value;
			}
		}
	}else 
	if(f.chkxoa.checked){
				dstv = f.chkxoa.value;
			}
	if(dstv == ""){
		alert('Vui lòng chọn thành viên cần xóa...');
		
		return false;
	}
	if(confirm('Bạn chắc muốn xóa thành viên này không?')){
		document.frmDLxoa.ten_dn.value=dstv;
		
		document.frmDLxoa.submit();
	}
}
</script>
<?php
	if(isset($_POST['txttimtv']))
	{
		$nd_tim = $_POST['txttimtv'];
	}
	$sql="SELECT * FROM thanh_vien WHERE TEN_DN LIKE '%$nd_tim%' ORDER BY TEN_DN";
	//echo $sql;exit;
	$rs=mysql_query($sql);
?>
////
<div class="article">
<form name="frmdstv">
<table width="643px" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
	<td colspan="13" align="right"><a href="index.php?noidung=dstv" ><font size="+1">Tất cả thành viên</font></a></td>
  </tr> 
  <tr>
	<td>&nbsp</td>
  </tr>
  <tr>
    <td colspan="9" style="text-align:center" class="title_ds"><h2><b>Danh sách thành viên</b></h2></td>
  </tr>
  <tr>
    <td align="center" class="title_ds">STT</td>
    <td align="center" class="title_ds">TÊN ĐĂNG NHẬP</td>
    <td align="center" class="title_ds">MẬT KHẨU</td>
    <td align="center" class="title_ds">EMAIL</td>
    <td align="center" class="title_ds">SỐ ĐIỆN THOẠI</td>
	<td align="center" class="title_ds">ĐỊA CHỈ</td>
	<td align="center" class="title_ds">QUYỀN</td>
    <td align="center" class="title_ds">Sửa</td>
    <td align="center" class="title_ds">Xóa</td>
  </tr>
<?php
	$i=0;
	while($rw=mysql_fetch_array($rs)){
		$i++;						
?>
  <tr>
    <td class="css_stt"><?php  echo $i; ?></td>
    <td class="grid"><?php echo $rw['TEN_DN'] ?>&nbsp;</td>
    <td class="grid"><?php echo $rw['MAT_KHAU'] ?>&nbsp;</td>
    <td class="grid"><?php echo $rw['EMAIL'] ?>&nbsp;</td>
    <td class="grid"><?php echo $rw['SO_DT'] ?>&nbsp;</td>
    <td class="grid"><?php echo $rw['DIA_CHI'] ?>&nbsp;</td>
    <td class="grid"><?php echo $rw['MS_QUYEN']?>&nbsp;</td>
    <td align="center" class="grid"><img src="images/edit.gif" border="0" onClick="mo_form_sua('<?php echo $rw['TEN_DN'];?>')"/></td>
    <td align="center"><span class="grid"><input type="checkbox" name="chkxoa" value="<?php echo $rw['TEN_DN']; ?>  " /></span></td>
  </tr>
<?php
	} 
?>

</table>
</form>
<div align="center"><input type="button" name="them" id="them" value="Thêm thành viên" onclick="location.href='index.php?noidung=ttv'"/>&nbsp;&nbsp;&nbsp;&nbsp;
<input type="button" name="xoa" id="xoa" value="Xóa" onClick="thuchienxoa()"/></div>
<form name="frmDLxoa" action="thanh_vien/xoa_thanh_vien.php" method="post">
<input type="hidden" name="ten_dn" value=""/>
</form>

<form name="frmDLsua" method="post" action="index.php?noidung=stv">
<input type="hidden" name="ten_dn" value="">
</form>
</div>